//浅拷贝
// var obj = {
//     name:"feng",
//     age:18,
//     car:['宝马','奔驰','五菱宏光']
// }

// var obj2 = {}

// function extend(obj,obj2){
//     for(item in obj){
//         obj2[item] = obj[item]
//     }
// }
// extend(obj,obj2)
// console.dir(obj)
// console.dir(obj2)
//深拷贝 
var obj3 = {
    name :'fengzhilun',
    age :19,
    car :['摇摇车','木马','电动车'],
    dog :{
        name :'旺财',
        age :'18'
    }

}
var obj4 ={}

function extend2(obj3,obj4){
    for(key in obj3){
        if(obj3[key] instanceof Array){
            obj4[key] = [];
            extend2(obj3[key],obj4[key]);
        }else if(obj3[key] instanceof Object){
            obj4[key] = [];
            extend2(obj3[key],obj4[key]);
        }else{
            obj4[key] = obj3[key]
        }
    }
}
extend2(obj3,obj4);

// console.dir(obj3)
console.dir(obj4)
console.dir(obj3.car === obj4.car)